﻿using BCT.Domains;
using BCT.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace BCT.Api.Controllers
{
    public class UserManageController : ApiController
    {
        private readonly IUserManageDomain _userManageDomain;

        public UserManageController(UserManageDomain userManageDomain)
        {
            _userManageDomain = userManageDomain;
        }
        [HttpGet, HttpPost]
        public Response GetUserList([FromBody]ConditionModel model)
        {
            var userList = _userManageDomain.GetUserList(model);
            return new Response() { data = userList.Data,count = userList.Count };
        }
        public Response ModefyUser(UserModel model)
        {
            var user = _userManageDomain.ModefyUser(model);
            if(user== "修改成功！")
            {
                return new Response() { data = user };
            }
            else
            {
                return new Response() { data = user,msg = "false" };
            }
        }
        [HttpGet, HttpPost]
        //public Response GetPowerList()
        //{
        //    var powerList = _userManageDomain.GetPowerList();
        //    return new Response() { data = powerList };
        //}
        public Response AddUser(UserModel model)
        {
            var user = _userManageDomain.AddUser(model);
            return new Response() { data = user };
        }
        public Response LogDelete(UserModel model)
        {
            var user = _userManageDomain.LogDelete(model);
            return new Response() { data = user };
        }
    }
}
